#!/bin/bash

del_old_file()
{
	for i in {0..10}; 
	do
			target_file=/mnt/beagle-v-ahead-factory/demo_save_img_IMX219_ch0_7_$i
			if test -f "$target_file"; then
				rm "$target_file"
			fi
	done
}

check_new_file()
{
	for i in {0..9}; 
	do
			target_file=/mnt/beagle-v-ahead-factory/demo_save_img_IMX219_ch0_7_$i
			if test -f "$target_file" && stat -c "%s" $target_file | grep 3110400; then
				echo "$target_file"
			else
				echo "CSI0 test fail"
				exit 1
			fi
	done
	del_old_file
	echo "CSI1 test pass"
}


./leds all off
./leds -t 1000 3 &
pid_leds=$!

del_old_file
sleep 0.5
/usr/share/vi/isp/test/camera_demo1 0 0 1 0 1920 1080 1 30 7
sleep 0.5
check_new_file

kill -9 "$pid_leds"
./leds 3 off
